#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include<weatherdate.h>
#include <QLabel>
#include <QList>
class QMenu;
class QAction;
class QString;
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    QMenu * mExitMenu;//右键退出菜单
    QAction *mExitAct;//退出行为
    QPoint mOffset;//窗口移动时鼠标与窗口左上角的偏移。

    QNetworkAccessManager *mNetworkAccessManager;

    Today mToday;
    Day mDay[6];
private slots:
    void onReplied(QNetworkReply *reply);
    void on_pushButton_clicked();

protected:
    void contextMenuEvent(QContextMenuEvent *event);

    void mousePressEvent(QMouseEvent *event);

    void mouseMoveEvent(QMouseEvent *event);
    //获取数据
    void getWeatherInfo(QString cityCode);
    //解析数据
    void parseJSON(QByteArray& byteArray);
    //更新ui
    void updateUI();
    //重写父类eventFilter方法
    bool eventFilter(QObject* watched,QEvent* event);

    //绘制高低温曲线
    void paintHighCurve();
    void paintLowCurve();
private:
    //星期和日期
    QList<QLabel*> mWeekList;
    QList<QLabel*> mDateList;

    //天气和天气图标
    QList<QLabel*> mTypeList;
    QList<QLabel*> mTypeIconList;

    //天气污染指数
    QList<QLabel*> mAqiList;

    //风力和风向
    QList<QLabel*> mFxList;
    QList<QLabel*> mFlList;

    QMap<QString, QString> mTypeMap;

};
#endif // MAINWINDOW_H
